//
//  JPFLog.h
//  JPFDebug
//
//  Created by JPFei on 2019/3/5.
//  Copyright © 2019 nmo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <JPFCoreKit/JPFCoreKit.h>


typedef enum : NSUInteger {
    JPFLogLevel_All,
    JPFLogLevel_Debug,
    JPFLogLevel_Info,
    JPFLogLevel_Error,
    JPFLogLevel_None,
} JPFLogLevel;

typedef enum : NSUInteger {
    JPFLogOutType_CMD = 1<<0,
    JPFLogOutType_File = 1<<1,
    JPFLogOutType_Service = 1<<2,
} JPFLogOutType;


@interface NSString (URL)


@end


@interface JPFLog : NSObject


+ (void)setupWithAppkey:(NSString *)appkey;
+ (instancetype)sharedInstance;

@property (nonatomic, assign) JPFLogLevel logLevel;
@property (nonatomic, assign) JPFLogOutType outType;

//default http://172.16.56.77/log/save1.0.0.php
@property (nonatomic, strong) NSString *serviceURL;
//default http://172.16.56.77/uploadfile/upload_file.php
@property (nonatomic, strong) NSString *fileUploadURL;

+ (void)log:(NSString *)str tag:(NSString *)tag level:(JPFLogLevel)level;
+ (void)log:(NSString *)str level:(JPFLogLevel)level;
+ (void)log:(NSString *)str;


//当前日志文件
- (NSString *)currentLogFile;

- (void)reesetLogfile;

- (void)submitImage:(NSArray *)imgArr
            imgName:(NSString *)imgName
              level:(JPFLogLevel)level
         completion:(void (^)(BOOL success,NSDictionary *info, NSString *message))completion;

- (void)submitFiles:(NSArray<JPFFileModel*> *)arrFiles
              level:(JPFLogLevel)level
         completion:(void (^)(BOOL success,NSDictionary *info, NSString *message))completion;

@end
//[NSString stringWithFormat:@"%@:%d %@\n%@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd),[NSString stringWithFormat:@"%@",self]]]
//#define NSLog (FORMAT, ...) [JPFLog log:[NSString stringWithFormat:@"%@:%d %@\n%@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd),[NSString stringWithFormat:FORMAT, ##__VA_ARGS__]]];
//#define NSLog(format,...) [JPFLog log:[NSString stringWithFormat:@"%@:%d %@\n%@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd),[NSString stringWithFormat:format, ##__VA_ARGS__]] level:JPFLogNone]

#define JPFLOG_VERSION @"1.0.0"

#define JPFLogData(levelVal,tagVal,format,...) [JPFLog log:[NSString stringWithFormat:@"%@:%d %@\n%@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd),[NSString stringWithFormat:format, ##__VA_ARGS__]] tag:tagVal level:levelVal]


#define JPFLogNone(format,...) [JPFLog log:[NSString stringWithFormat:format, ##__VA_ARGS__] tag:[NSString stringWithFormat:@"%@:%d %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd)] level:JPFLogLevel_None]

#define JPFLogDebug(format,...) [JPFLog log:[NSString stringWithFormat:format, ##__VA_ARGS__] tag:[NSString stringWithFormat:@"%@:%d %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd)] level:JPFLogLevel_Debug]

#define JPFLogInfo(format,...) [JPFLog log:[NSString stringWithFormat:format, ##__VA_ARGS__] tag:[NSString stringWithFormat:@"%@:%d %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd)] level:JPFLogLevel_Info]

#define JPFLogError(format,...) [JPFLog log:[NSString stringWithFormat:format, ##__VA_ARGS__] tag:[NSString stringWithFormat:@"%@:%d %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd)] level:JPFLogLevel_Error]

#define JPFLogAll(format,...) [JPFLog log:[NSString stringWithFormat:format, ##__VA_ARGS__] tag:[NSString stringWithFormat:@"%@:%d %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,NSStringFromSelector(_cmd)] level:JPFLogLevel_All]


/*#ifdef DEBUG

#else


#define JPFLogNone(format,...)

#define JPFLogDebug(format,...)

#define JPFLogInfo(format,...)

#define JPFLogError(format,...)

#define JPFLogAll(format,...)

#endif
*/

#define nstr(format,...) [NSString stringWithFormat:format,__VA_ARGS__]

//#define NSLog1(FORMAT, ... ) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
///NSLog(@"%s %d \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
///fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
//NSLog(@"%d \n %@:%@\n\n",__LINE__,[AppDelegate userName],[NSString stringWithFormat:__VA_ARGS__])
///NSLog(@"%s %d \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
///NSLog( @"< %@:(%d) > %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__,  ##__VA_ARGS__ )

